package services

import (
	"context"
	"k8sops/pkg/client"
	"log"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/metrics/pkg/apis/metrics/v1beta1"
)

func GetNodeMetrics() (nodeMetrics *v1beta1.NodeMetricsList, err error) {
	k := client.K8sClientSet{}
	c, err := k.GetMetricsClientset()
	if err != nil {
		log.Fatal(err.Error())
		return
	}

	nodeMetrics, err = c.MetricsV1beta1().NodeMetricses().List(context.TODO(), metav1.ListOptions{})
	if err != nil {
		log.Fatal(err.Error())
		return
	}

	return
}
